package org.bigdata.platform.csv;

import java.util.List;

import org.bigdata.platform.IIteratorFileObject;
import org.bigdata.platform.IteratorElement;
/**
 * All the implementations of this interface would write data into
 * CSV files or read data from CSV files. They should handle custom
 * separators along with escaping and custom escape characters as 
 * well.
 * @author mayuresh
 *
 */
public interface ICsvFileObject<E> extends IIteratorFileObject<IteratorElement<E>> {
	/**
	 * Default separator used by the implementations if custom separator
	 * has not been set.
	 */
	String DEFAULT_SEPARATOR = ",";
	/**
	 * Default escape character used by the implementations if custom
	 * escape character has not been set.
	 */
	char DEFAULT_ESCAPE_CHAR = '\\';
	/*
	 * Methods mostly called while reading the file
	 */
	/**
	 * Returns the number of columns present in the CSV file represented
	 * by this object.
	 * @return - Number of columns
	 */
	int getColumnCount();
	/**
	 * Returns true if the ignore headers flag is set to true. It means 
	 * no headers will be present in the target CSV file.
	 * @return - true if the headers are ignored
	 */
	boolean ignoreHeaders();
	/**
	 * Returns CsvColumn object for the column present at the given index.
	 * First index is always "1"
	 * @param indexStartwWith1
	 * @return - CsvColumn present at the given index
	 */
	CsvColumn getColumn(int indexStartwWith1);
	/**
	 * Returns separator string used to parse or write the CSV file.
	 * @return - Separator string
	 */
	String getSeparator();
	/**
	 * Returns escape character used to escape separator string if it 
	 * comes as a part of data.
	 * @return
	 */
	char getEscapeChar();

	/*
	 * Methods mostly called while writing into the file
	 */
	/**
	 * Change custom separator.
	 * @param separator - Separator string
	 */
	void setSeparator(String separator);
	/**
	 * Tells whether the CSV file will have headers or not
	 * @param ignoreHeaders - ignoreHeaders flag
	 */
	void setIgnoreHeaders(boolean ignoreHeaders);
	/**
	 * Set columns of the CSV. Mostly used while writing data into CSV file.
	 * @param columns
	 */
	void setColumns(List<CsvColumn> columns);
	/**
	 * Set custom escape character
	 * @param escapeChar - Custom escape character
	 */
	void setEscapeChar(char escapeChar);
}
